package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:使用lambda表达式创建线程
 * User: bjc
 * Date: 2025-08-14
 * Time: 20:26
 */
public class ThreadDemo6 {
    public static void main(String[] args) {
        Thread t = new Thread(
                () -> {
                    while (true) {
                        System.out.println("hello runnable");
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
        );
        //开启线程
        t.start();
        while (true) {
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
